Fallback to folder if worktree creation fails in bg sessions#3277
Merged
DonJayamanne merged 3 commits intomainfrom Jan 29, 2026
Merged
Fallback to folder if worktree creation fails in bg sessions#3277DonJayamanne merged 3 commits intomainfrom
DonJayamanne merged 3 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request aims to fix the fallback behavior when worktree creation fails, ensuring that the system properly falls back to using the workspace folder without worktree isolation.
Changes:
- Modified the initialization of
workingDirectoryto usesessionWorkspaceFolderas a fallback - Updated
isWorkspaceFolderWithoutRepoflag totruewhen no repository is selected - Updated
isWorkspaceFolderWithoutRepoflag totruewhen worktree creation fails
Comments suppressed due to low confidence (2)
src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts:1115
- The ternary condition on
selectedRepositoryis unnecessary becauseselectedRepositoryis always undefined at this point (it's declared asundefinedon line 1114). This line will always evaluate tosessionWorkspaceFolder. Consider simplifying to:const workingDirectory = sessionWorkspaceFolder;
const workingDirectory = selectedRepository ? this.workspaceService.getWorkspaceFolder(selectedRepository) : sessionWorkspaceFolder;
src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts:1148
- When worktree creation fails at line 1148,
workingDirectorymay be undefined even thoughselectedRepositoryis defined. TheworkingDirectoryvariable is set at line 1115 beforeselectedRepositoryis potentially assigned (at lines 1120 or 1131). When falling back from a failed worktree creation, consider usingthis.workspaceService.getWorkspaceFolder(selectedRepository)to get the proper workspace folder for the repository, rather than relying on the staleworkingDirectoryvalue that was calculated beforeselectedRepositorywas known.
return { workingDirectory, worktreeProperties: undefined, isWorkspaceFolderWithoutRepo: true, cancelled: false };
src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts
Outdated
Show resolved
Hide resolved
lszomoru
approved these changes
Jan 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes microsoft/vscode#291641